import Vue from 'vue'
import co from 'co'

let seleGen = function * () {
  try {

  } catch (error) {
    // 异常处理
  }
}

let SqlService = {
  install (Vue, options) {
    // 给vue增添对话框显示方法
    Vue.SqlService = Vue.prototype.$SqlService = SqlService
  },
  getOper () {
    let sele = seleGen()
    return co(sele)
  },
  // 单表查询 {model: {tablename: tablename, condition: 'condition'}}
  singleTable (tablename, condition) {
    return Vue.post('rs/sql/singleTable', {data: {tablename: tablename, condition: condition}}, {resolveMsg: null, rejectMsg: null})
  },
  // 单表查询排序
  singleTableOrderBy (data) {
    return Vue.post('rs/sql/singleTable_OrderBy', {data: data}, {resolveMsg: null, rejectMsg: null})
  },
  singleValue (sql, condition) {
    return Vue.resetpost('rs/logic/getOneData', {data: {sql: sql, params: condition}}, {resolveMsg: null, rejectMsg: null})
  },
  getRecord (type, id) {
    return Vue.resetpost('rs/sql/singleTable_RecordOne', {data: {tabletype: type, f_userinfo_id: id}}, {resolveMsg: null, rejectMsg: null})
  },
  getReplaceTime (data) {
    return Vue.resetpost('rs/sql/singleTable_Count1', {data: {tablename: data.tablename, condition: 'f_user_id=' + "'" + data.f_user_id + "'"}}, {resolveMsg: null, rejectMsg: '获取补卡次数失败'})
  }
}

export default SqlService
